/* 人员 基础设置方案 */

import { ajaxService } from '@/utils/request';
import * as typeObj from './type';

const env = import.meta.env;
// const baseURL1 = env.VITE_API_BASE_URL;
const baseURL1 = env.VITE_DEV_BASE_URL; // const baseURL = 'http://192.168.31.129:39003';
// const baseURL = 'http://192.168.31.129:39003';
const baseURL = env.VITE_DEV_BASE_URL;
// const baseURL = env.VITE_APP_BASE_URL;
const baseURL2 = env.VITE_APP_BASE_URL;
const baseURL3 = 'http://192.168.0.178:30058';
const baseURL4 = env.VITE_DEV_BASE_URL;

/**
 * 获取入职方案模板
 */
export function GetEntryScheme(
  params: typeObj.settingPage & { name?: string; required?: 1 }
) {
  return ajaxService({
    url: '/pl/organization/personnel/set/onboardingTemplate',
    method: 'get',
    params,
    baseURL
  });
}

/**
 * 获取入职方案明细查询
 */
export function GetEntrySchemeById(params: { id: number }) {
  return ajaxService({
    url: '/pl/organization/personnel/set/onboardingTemplateById',
    method: 'get',
    params,
    baseURL
  });
}

/**
 * 删除入职方案模板
 */
export function DelEntryScheme(data: { id: number }) {
  return ajaxService({
    url: '/pl/organization/personnel/set/onboardingTemplate',
    method: 'DELETE',
    data,
    baseURL
  });
}
/**
 * 新增入职方案模板
 */
export function AddEntryScheme(data: any) {
  return ajaxService({
    url: '/pl/organization/personnel/set/onboardingTemplate',
    method: 'post',
    data,
    baseURL
  });
}

/**
 * 编辑入职方案模板
 */
export function EditEntryScheme(data: any) {
  return ajaxService({
    url: '/pl/organization/personnel/set/onboardingTemplate',
    method: 'put',
    data,
    baseURL
  });
}
/**
 * 修改默认入职方案模板
 */
export function EditEntrySchemeDefault(data: { id: number }) {
  return ajaxService({
    url: '/pl/organization/personnel/set/onboardingTemplateDefault',
    method: 'put',
    data,
    baseURL
  });
}

/**
 * 获取入职通知模板
 */
export function GetBonboardingInform(
  params: typeObj.settingPage & { name?: string; type: number }
) {
  return ajaxService({
    url: '/hr/personnel_matters/basic_setting/onboarding_settings/onboarding_notice/template',
    method: 'get',
    params,
    baseURL
  });
}

/**
 * 获取入职通知模板详情
 */
export function GetBonboardingInformDetail(params: { id: number }) {
  return ajaxService({
    url: '/hr/personnel_matters/basic_setting/onboarding_settings/onboarding_notice/template/detail',
    method: 'get',
    params,
    baseURL
  });
}

/**
 * 删除入职通知模板
 */
export function DelBonboardingInform(data: { ids: number[] }) {
  return ajaxService({
    url: '/hr/personnel_matters/basic_setting/onboarding_settings/onboarding_notice/template',
    method: 'DELETE',
    data,
    baseURL
  });
}

/**
 * 删除入职通知子模板
 */
export function DelOnboardingInformTemplateDetail(data: { ids: number[] }) {
  return ajaxService({
    url: 'hr/personnel_matters/basic_setting/onboarding_settings/onboarding_notice/template/content/detail',
    method: 'DELETE',
    data,
    baseURL
  });
}

/**
 * 新增入职通知子模板
 */
export function AddOnboardingInformTemplateDetail(data: { id?: number }) {
  return ajaxService({
    url: '/pl/organization/personnel/set/onboardingInformTemplateDetail',
    method: 'post',
    data,
    baseURL
  });
}

/**
 * 新增入职通知模板
 */
export function AddBonboardingInform(data: any) {
  return ajaxService({
    url: '/hr/personnel_matters/basic_setting/onboarding_settings/onboarding_notice/template',
    method: 'POST',
    data,
    baseURL
  });
}

/**
 * 修改入职通知模板
 */
export function EditBonboardingInform(data: any) {
  return ajaxService({
    url: '/hr/personnel_matters/basic_setting/onboarding_settings/onboarding_notice/template',
    method: 'PUT',
    data,
    baseURL
  });
}

/**
 * 修改默认入职通知模板
 */
export function EditBonboardingInformDefault(data: {
  id?: number; // 默认模板的id
  type: 1 | 2; // 1短信通知 2邮件通知
  enable?: 1 | 2; // 1启用 2关闭
  ids: number[]; // 是否启用的id
}) {
  return ajaxService({
    url: '/hr/personnel_matters/basic_setting/onboarding_settings/onboarding_notice/template/status',
    method: 'put',
    data,
    baseURL
  });
}

/**
 * 查询入职通知模板查重
 */
export function RepeatSchemePeople(params: { name: string; tType: number }) {
  return ajaxService({
    url: '/hr/personnel_matters/basic_setting/onboarding_settings/onboarding_notice/template/repeat',
    method: 'get',
    params,
    baseURL
  });
}

/**
 * 获取入职手续
 */
export function GetSchemePeople() {
  return ajaxService({
    url: '/pl/organization/personnel/procedureTemplateCopy',
    method: 'get',
    baseURL
  });
}

/**
 * 获取入职手续模板设置
 */
// export function GetOnboardingProcedure(
//   params: typeObj.settingPage & { name?: string }
// ) {
//   return ajaxService({
//     url: '/pl/organization/personnel/onboardingProcedure',
//     method: 'get',
//     params,
//     baseURL
//   });
// }
/**
 * 获取入职手续模板设置
 */
export function GetOnboardingProcedure(params: typeObj.Params) {
  return ajaxService({
    url: '/hr/personnel_matters/template',
    method: 'get',
    params,
    baseURL: baseURL2
  });
}
/**
 * 手续模板新增查重
 * ownerType 1入职 2离职
 */
export function RepeatOnboardingProcedure(params: {
  name?: string;
  ownerType: 2 | 3;
}) {
  return ajaxService({
    url: '/hr/personnel_matters/template/repeat',
    method: 'get',
    params,
    baseURL
  });
}

/**
 * 入职手续模板查询明细
 */
export function GetOnboardingProcedureById(params: { id?: number }) {
  return ajaxService({
    url: '/hr/personnel_matters/template/detail',
    method: 'get',
    params,
    baseURL: baseURL2
  });
}
/**
 * 获取手续清单列表
 * @param params
 * @returns
 */
export function GetProcedureList(params: {
  ownerId: number;
  ownerType: number;
}) {
  return ajaxService({
    url: '/hr/personnel_matters/basic_setting/onboarding_leave_office_procedure_list/procedure/list',
    method: 'get',
    params,
    baseURL: baseURL3
  });
}

/**
 * 删除入职手续模板设置
 */
export function DelOnboardingProcedure(data: any) {
  return ajaxService({
    url: '/hr/personnel_matters/template',
    method: 'DELETE',
    data,
    baseURL: baseURL3
  });
}

/**
 * 删除入职手续子模板材料设置
 */
export function DelOnboardingProcedureDetails(params: { ids: number[] }) {
  return ajaxService({
    url: '/hr/personnel_matters/basic_setting/onboarding_leave_office_procedure_list/procedure/list',
    method: 'DELETE',
    params,
    baseURL: baseURL3
  });
}

/**
 * 删除入职手续清单
 */
export function DelProcedure(data: { ids: number[]; delType: number }) {
  return ajaxService({
    url: '/hr/personnel_matters/basic_setting/onboarding_leave_office_procedure_list/procedure/list',
    method: 'DELETE',
    data,
    baseURL: baseURL3
  });
}

/**
 * 新增入职手续子模板材料设置
 */
export function AddOnboardingProcedureDetails(data: any) {
  return ajaxService({
    url: '/hr/personnel_matters/basic_setting/onboarding_leave_office_procedure_list/procedure/list',
    method: 'POST',
    data,
    baseURL: baseURL3
  });
}

/**
 * 修改入职手续子模板材料设置
 */
export function PutOnboardingProcedureDetails(data: any) {
  return ajaxService({
    url: '/hr/personnel_matters/basic_setting/onboarding_leave_office_procedure_list/procedure/list',
    method: 'PUT',
    data,
    baseURL: baseURL3
  });
}
/**
 * 修改入职手续子模板材料设置
 */
export function PutOnboardingProceduretemplate(data: any) {
  return ajaxService({
    url: '/pl/organization/personnel/onboardingProcedureControlShow',
    method: 'PUT',
    data,
    baseURL
  });
}

/**
 * 新增入职手续模板设置
 */
export function AddOnboardingProcedure(data: any) {
  return ajaxService({
    url: '/hr/personnel_matters/template',
    method: 'POST',
    data,
    baseURL: baseURL2
  });
}
/**
 * 修改入职手续模板设置
 */
export function EditOnboardingProcedure(data: any) {
  return ajaxService({
    url: '/hr/personnel_matters/template',
    method: 'PUT',
    data,
    baseURL: baseURL2
  });
}
/**
 * 修改入职手续模板状态
 */
export function EditOnboardingProcedureStatus(data: {
  ids: number[];
  enable: number;
}) {
  return ajaxService({
    url: '/hr/personnel_matters/template/enable',
    method: 'PUT',
    data,
    baseURL: baseURL2
  });
}

/**
 * 修改默认入职手续模板设置
 */
export function EditOnboardingProcedureDefault(data: {
  id: number;
  ownerType: number;
}) {
  return ajaxService({
    url: '/hr/personnel_matters/template/default',
    method: 'PUT',
    data,
    baseURL: baseURL2
  });
}
/**
 *  修改入职表头;
 * node wait_show 修改待入职列表 bespeak_show 修改预入职列表 onboarding_show 修改入职办理列表 abandon_show 修改放弃入职列表;
 * show 1：显示 2：不显示
 */
export function EditOnboardingWords(data: {
  id?: number;
  node?: string;
  show?: number;
}) {
  return ajaxService({
    url: '/pl/organization/personnel/set/onboardingWords',
    method: 'put',
    data,
    baseURL
  });
}

/**
 * 入职表头查询
 */
export function GetOnboardingWords() {
  return ajaxService({
    url: '/pl/organization/personnel/set/onboardingWords',
    method: 'get',
    baseURL
  });
}

/**
 * 入职表头查询
 */
export function PostOnboardingWords(data: any) {
  return ajaxService({
    url: '/pl/organization/personnel/set/onboardingWords',
    method: 'POST',
    data,
    baseURL
  });
}

/**
 * 入职数据修改
 * node: 1待入职 2:预入职 3:入职办理 4:放弃入职
 */
export function EditOnboarding(data: any) {
  return ajaxService({
    url: '/pl/organization/personnel/set/onboarding',
    method: 'put',
    data,
    baseURL
  });
}

/**
 * 入职节点修改
 * node: 1待入职 2:预入职 3:入职办理 4:放弃入职
 */
export function EditOnboardingNode(data: {
  ids?: number[];
  node: number;
  enterIf: number;
  nums?: {
    useScope: string;
    positionSequenceId: number;
    userId: number;
  }[];
}) {
  return ajaxService({
    url: '/pl/organization/personnel/set/onboardingNode',
    method: 'put',
    data,
    baseURL
  });
}

/**
 * 入职数据删除
 * node: 1待入职 2:预入职 3:入职办理 4:放弃入职
 */
export function DelOnboarding(data: { ids: number[] }) {
  return ajaxService({
    url: '/pl/organization/personnel/set/onboarding',
    method: 'DELETE',
    data,
    baseURL
  });
}

/**
 * 入职状态查询
 * node: 1待入职 2:预入职 3:入职办理 4:放弃入职
 */
export function GetOnboarding(
  params: typeObj.settingPage & {
    name?: string;
    node: number;
    projectId?: string;
  }
) {
  return ajaxService({
    url: '/pl/organization/personnel/set/onboarding',
    method: 'get',
    params,
    baseURL
  });
}

/**
 * 入职申请查询
 * node: 1：待审核 2：审核通过 3：审核不通过
 */
export function GetApply(params: typeObj.settingPage & { node: number }) {
  return ajaxService({
    url: '/pl/organization/personnel/apply',
    method: 'get',
    params,
    baseURL
  });
}

/**
 * 删除入职申请
 */
export function DelApply(data: { ids: number[] }) {
  return ajaxService({
    url: '/pl/organization/personnel/apply',
    method: 'DELETE',
    data,
    baseURL
  });
}

/**
 * 新增入职人员
 */
export function AddOnboarding(data: any) {
  return ajaxService({
    url: '/pl/organization/personnel/set/onboarding',
    method: 'POST',
    data,
    baseURL
  });
}
/**
 * 新增入职人员
 */
export function AddNewStaff(data: typeObj.NewStaffInfo) {
  return ajaxService(
    {
      url: '/hr/personnel_matters/roster/personnel/list',
      method: 'POST',
      data,
      baseURL
    },
    {
      message: '新增成功'
    }
  );
}
/**
 * 修改入职人员
 */
export function PutNewStaff(data: typeObj.NewStaffInfo) {
  return ajaxService({
    url: '/hr/personnel_matters/roster/personnel/list',
    method: 'PUT',
    data,
    baseURL: baseURL2
  });
}
/**
 * 获取入职人员
 */
export function GetStaff(params: typeObj.PersonnelListParams) {
  return ajaxService({
    url: '/hr/personnel_matters/roster/personnel/list',
    method: 'GET',
    params,
    baseURL: baseURL1
  });
}
/**
 * 获取入职人员详情
 */
export function GetStaffDetails(params: { id: number }) {
  return ajaxService({
    url: '/hr/personnel_matters/roster/personnel/list/detail',
    method: 'GET',
    params,
    baseURL: baseURL2
  });
}
/**
 * 删除员工
 */
export function DelStaff(data: { ids: number[] }) {
  return ajaxService({
    url: '/hr/personnel_matters/roster/personnel/list',
    method: 'DELETE',
    data,
    baseURL: baseURL4
  });
}
/**
 * 新增员工
 */
export function AddStaff(data: {
  name: string;
  mobile: string;
  password: string;
}) {
  return ajaxService({
    url: '/user/staff',
    method: 'POST',
    data,
    baseURL: baseURL1
  });
}

/**
 * 入职人员新增
 */
export function AddPositionManage(data: any) {
  return ajaxService({
    url: '/pl/personnel/roster/detail',
    method: 'POST',
    data,
    baseURL
  });
}

/**
 * 工号配置查询
 */
export function GetScheme(params: typeObj.settingPage) {
  return ajaxService<typeObj.schemeType>({
    url: '/hr/personnel_matters/basic_setting/onboarding_settings/job_number_rule_settings/list',
    method: 'get',
    params,
    baseURL
  });
}

/**
 * 修改工号启用状态
 */
export function ChangeSchemeType(data: { type: 1 | 2; id: number }) {
  return ajaxService<typeObj.schemeType>({
    url: '/hr/personnel_matters/basic_setting/onboarding_settings/job_number_rule_settings/down',
    method: 'put',
    data,
    baseURL
  });
}

/**
 * 工号规则查重
 */
export function RepeatScheme(params: { name?: string; prefix?: string }) {
  return ajaxService<string>({
    url: '/hr/personnel_matters/basic_setting/onboarding_settings/job_number_rule_settings/repeat',
    method: 'get',
    params,
    baseURL
  });
}

/**
 * 工号配置新增
 */
export function PostScheme(data: typeObj.schemeType) {
  return ajaxService({
    url: '/hr/personnel_matters/basic_setting/onboarding_settings/job_number_rule_settings',
    method: 'post',
    data,
    baseURL
  });
}

/**
 * 根据组织id查工号规则
 */
export function CheckJobNumToOrganizaitonId(params: any) {
  return ajaxService({
    url: '/hr/personnel_matters/basic_setting/onboarding_settings/job_number_rule_settings/rule',
    method: 'get',
    params,
    baseURL
  });
}

/**
 * 工号配置修改
 */
export function EditScheme(data: typeObj.schemeType) {
  return ajaxService({
    url: '/hr/personnel_matters/basic_setting/onboarding_settings/job_number_rule_settings',
    method: 'put',
    data,
    baseURL
  });
}

/**
 * 工号配置批量修改order
 */
export function EditAllScheme(data: typeObj.schemeArray) {
  return ajaxService({
    url: '/hr/personnel_matters/basic_setting/onboarding_settings/job_number_rule_settings/array',
    method: 'put',
    data,
    baseURL
  });
}

/**
 * 工号配置删除
 */
export function DelScheme(data: typeObj.delArr) {
  return ajaxService({
    url: '/hr/personnel_matters/basic_setting/onboarding_settings/job_number_rule_settings',
    method: 'DELETE',
    data,
    baseURL
  });
}

/**
 * 手工工号规则查询
 */
export function GetManual() {
  return ajaxService<typeObj.manual>({
    url: '/hr/personnel_matters/basic_setting/onboarding_settings/job_number_rule_settings/manual',
    method: 'get',
    baseURL
  });
}

/**
 * 生成工号
 */
export function GetNum(params: any) {
  return ajaxService<any>({
    url: '/hr/personnel_matters/basic_setting/onboarding_settings/job_number_rule_settings',
    method: 'get',
    params,
    baseURL
  });
}

/**
 * 手工工号规则修改
 */
export function EditManual(data: typeObj.manual) {
  return ajaxService({
    url: '/hr/personnel_matters/basic_setting/onboarding_settings/job_number_rule_settings/manual',
    method: 'put',
    data,
    baseURL
  });
}

/**
 * 入职新增人员模板获取
 */
export function GetPeropleTemplate() {
  return ajaxService<any>({
    url: '/pl/organization/personnel/peropleTemplate',
    method: 'get',
    baseURL
  });
}

/**
 * 入职新增人员创建使用模板接口
 */
export function PostPeropleTemplateUse(data: any) {
  return ajaxService<any>({
    url: '/hr/personnel_matters/basic_setting/personnel_settings/template/use',
    method: 'post',
    data,
    baseURL: baseURL1
  });
}

/**
 * 入职新增人员模板新增
 */
export function PostPeropleTemplate(data: any) {
  return ajaxService<any>({
    url: '/pl/organization/personnel/peropleTemplate',
    method: 'POST',
    data,
    baseURL
  });
}

/**
 * 入职新增人员模板更新
 */
export function PutPeropleTemplate(data: any) {
  return ajaxService<any>({
    url: '/pl/organization/personnel/peropleTemplate',
    method: 'put',
    data,
    baseURL
  });
}

/**
 * 入职新增人员模板更新
 */
export function PutPersonnelid(data: { id: number; personnelId: number }) {
  return ajaxService<any>({
    url: '/pl/organization/personnel/personnelid',
    method: 'put',
    data,
    baseURL
  });
}

/**
 * 入职新增人员模板局部更新
 */
export function PostPeropleTemplateone(data: any) {
  return ajaxService<any>({
    url: '/pl/organization/personnel/peropleTemplateContorl',
    method: 'POST',
    data,
    baseURL
  });
}

/**
 * 入职通知
 */
export function GetInform(params: { id: number }) {
  return ajaxService<any>({
    url: '/pl/organization/personnel/getInform',
    method: 'get',
    params,
    baseURL
  });
}

/**
 * 入职列表明细
 */
export function GetonboardingById(params: { id: number }) {
  return ajaxService<any>({
    url: '/pl/organization/personnel/set/onboardingById',
    method: 'get',
    params,
    baseURL
  });
}

/**
 * 入职通知内容通过自选模板查询
 */
export function GetInformByTemolateId(params: {
  id: number;
  nodeId?: number; // 短信id
  emailId?: number; // 邮件id
}) {
  return ajaxService<any>({
    url: '/hr/personnel_matters/basic_setting/onboarding_settings/onboarding_notice/template/content',
    method: 'get',
    params,
    baseURL
  });
}

/**
 * 部门板查询
 */
export function GetlistData(params: any) {
  return ajaxService<any>({
    url: '/hr/organization/organization_manage/organizational_institution_list/institution/list/date',
    method: 'get',
    baseURL: baseURL1,
    params
  });
}
/**
 * 职位板查询
 */
export function GetByorg(params: any) {
  return ajaxService<any>({
    url: '/organization/position/position/byorg',
    method: 'get',
    baseURL: baseURL1,
    params
  });
}
/**
 *职位职层 板查询
 */
export function GetByid(params: any) {
  return ajaxService<any>({
    url: '/organization/position/positionLevel/byid',
    method: 'get',
    baseURL: baseURL1,
    params
  });
}

/**
 * 职位管理新增职位人员关系
 */
export function PostPositionPersonnele(data: any) {
  return ajaxService<any>({
    url: '/organization/position/position/personnel',
    method: 'POST',
    data,
    baseURL: baseURL1
  });
}

/**
 * 入职管理导出
 */
export function OnboardingExcel(data: any) {
  return ajaxService<any>({
    url: '/pl/organization/personnel/set/onboardingExcel',
    method: 'post',
    headers: {
      'Content-Type': 'multipart/form-data;charset=UTF-8'
    },
    // headers: { 'Content-Type': 'application/vnd.ms-excel;charset=utf8' },
    responseType: 'blob',
    baseURL: 'http://192.168.31.134:39003',
    data
  });
}

/**
 * 入职管理导入
 */
export function EOabcdegiilmnnooprrtx(data: any) {
  return ajaxService<any>({
    url: '/pl/organization/personnel/set/importOnboardingExcel',
    method: 'post',
    headers: {
      'Content-Type': 'multipart/form-data;charset=UTF-8'
    },
    // headers: { 'Content-Type': 'application/vnd.ms-excel;charset=utf8' },
    // responseType: 'blob',
    baseURL: 'http://192.168.31.134:39003',
    data
  });
}
